<div class="form-area" id="affix-form">
    <iframe id="upload-frame" name="upload-frame" style="display:none;"></iframe>
    <form action="http://fs1u.dajie.com/file/upload.php" method="post" enctype="multipart/form-data" id="upload_form" target="upload-frame" onsubmit="return false;">
        <div style="padding:0px 20px;">
            <div class="affix-tip">请使用易识别的附件名称，如“英文简历”，便于企业直观了解。</div>
            <table class="fileTable" style="margin:auto;">
                <col width="70"/>
                <col width="*"/>

                <tr>
                    <td class="b">选择文件：</td>
                    <td>
                        <input type="hidden" name="type" value="resume_affix"/>
                        <input id="upload_file" type="file" name="file"/>
                        <span id="fileError" style="display:none;" class="red">请浏览并选择文件</span>
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td class="g9">·支持jpg、doc、docx、pdf、txt格式<br/> ·单个附件大小不超过10M</td>
                </tr>
                <tr>
                    <td></td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a href="javascript:void(0);" id="upload-button" class="fresh margin"><span>保存</span></a><a href="javascript:void(0);" class="normal J_cancel" itemtype="affix"><span>取消</span></a>
                    </td>
                </tr>
            </table>
            <div class="fileLoading" style="display:none;">
                <p class="aligncenter"><img src="http://assets.dajieimg.com/images/icons/loading_16.gif" alt=""></p>
                <p class="aligncenter g9">上传中，请稍等...</p>
            </div>
        </div>
    </form>

    <script type="text/javascript">
        function UPLOAD_CALLBACK(r) {
            $(this).attr('disabled',false);
            var itemType = 'affix';
            if (r.substr(0, 2) == '1:') {
                alert(r.substr(2));
                $('.fileLoading').hide();
                $('.fileTable').show();
            } else {
                window.setTimeout(function() {
                    var affixs = r.split("|");
                    if (affixs.length < 4) {
                        alert("上传出错");
                    }
                    $.post('/resume/affix/create', {method:'do',displayName:affixs[0],size:parseInt(affixs[1]),fileType:affixs[2],saveName:affixs[3],serverId:1}, function(rs) {
                        var result = eval('(' + rs + ')');
                        if(result.statusCode == 0){
                            resultForm(itemType,result.data);
                            loadLayout();
                            hiddenAddBtn($('.J_event[rel="add"][itemtype="affix"]'))
                        }else{
                            alert(result.msg);
                        }
                    });
                }, 10);
            }
        }
        $('#upload-button').click(function(){
            if($('#upload_file').val() !== ""){
                var file =$('#upload_file').val().split('.');
                var fileType = file[file.length - 1];
                if(fileType == 'txt' || fileType == 'jpg'|| fileType == 'pdf'|| fileType == 'doc'|| fileType == 'docx'
                        ||fileType == 'TXT' || fileType == 'JPG'|| fileType == 'PDF'|| fileType == 'DOC'|| fileType == 'DOCX'){
                    $('#upload_form').ajaxSubmit({timeout:1000*60*10});
                    $('.fileTable').hide();
                    $('.fileLoading').show();
                    $(this).attr('disabled',true);
                    setTimeout("$(this).attr('disabled',false)",1000*60*10)
                }else{
                    $('#fileError').text('仅支持jpg、doc、docx、pdf、txt格式').show();
                    return false;
                }
            }else{
                $('#fileError').show();
                return false;
            }
        });
        $('#upload-button').blur(function(){
            $('#fileError').hide();
        });

    </script>

</div>